﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;

namespace FinalWeb
{
    public partial class UserPersonal : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            txtNewPwd.Focus();
            this.lblUserIN.Text = "您好！" + Session["UserName"].ToString();
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strCn = "server=pc.hstc.cn;database=dhd2014112102;uid=2014112102;pwd=19960523";
            SqlConnection cn = new SqlConnection(strCn);
            try
            {
                cn.Open();
                string strSql = "UPDATE  UserInfo SET   Password = N'"+this.txtNewPwd.Text+"' WHERE   (UserName = N'"+this.txtName.Text+"')";

                SqlCommand cmd = new SqlCommand(strSql, cn);
                int iUpd = cmd.ExecuteNonQuery();
                if (iUpd < 1)
                {
                    Response.Write(@"<script>alert('更改失败！');</script>");
                }
                else
                {
                    Response.Write(@"<script language=javascript>alert('更改成功！');window.window.location.href='UserLogin.aspx';</script>");
                }
            }
            catch (Exception ex)
            {
                this.lblMessage.Text = ex.Message;
            }
            finally
            {
                cn.Close();
            }
        }

        protected void btnIndex_Click(object sender, EventArgs e)
        {
            Response.Write(@"<script>alert('注销成功，欢迎下次登陆！');</script>");
        }
    }
}